package edu.cmu.cs211.pg.internal;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.junit.Test;

import edu.cmu.cs211.pg.graph.MyDirectedGraph;
import edu.cmu.cs211.pg.graph.WeightedEdge;

public class MyDirectedGraphTest {

	/*
	 * creates a directed graph and tests to make sure its methods are working correctly
	 */
	@Test
	public void FindDijError() {
		HashSet<Integer> hs = new HashSet<Integer>();
		hs.add(0);
		hs.add(1);
		hs.add(2);
		hs.add(3);
		hs.add(4);
		
		HashSet<WeightedEdge<Integer>> edges = new HashSet<WeightedEdge<Integer>>();
		WeightedEdge we = new WeightedEdge(0,1,1);
		WeightedEdge we2 = new WeightedEdge(1,2,1);
		WeightedEdge we3 = new WeightedEdge(2,3,1);
		WeightedEdge we4 = new WeightedEdge(3,4,1);
		edges.add(we);
		edges.add(we2);
		edges.add(we3);
		edges.add(we4);
		
		MyDirectedGraph<Integer, WeightedEdge<Integer>> g = new MyDirectedGraph(hs, edges);
		
		Set set = g.outgoingEdges((Integer) 3);
		
		Iterator i = set.iterator();
		while (i.hasNext()) {
			System.out.println(i.next());
		}

	}
	
	/*
	 * tests specifically for the outgoing edges from several vertices 
	 * in the directed graph
	 */
	@Test
	public void OutGoingEdgesTest() {
		HashSet<Integer> hs = new HashSet<Integer>();
		for(int i = 0; i <= 50; i++) {
			hs.add(i);
		}
		
		HashSet<WeightedEdge<Integer>> edges = new HashSet<WeightedEdge<Integer>>();
		for(int i = 0; i < 50; i++) {
			edges.add(new WeightedEdge(i, i+1, 1));
		}

		MyDirectedGraph<Integer, WeightedEdge<Integer>> g = new MyDirectedGraph(hs, edges);

		Set set = g.outgoingEdges((Integer) 49);

		Iterator i = set.iterator();
		while (i.hasNext()) {
			System.out.println(i.next());
		}

	}
}
